There are some table we would like to include in the latex document, but we first have to format them to meet the requirements. Specifically, these are the tables of significant disease enrichment results.
In [1]:
cd ../../HBP/
In [2]:
import csv
In [9]:
import numpy as np
In [66]:
from pylab import *
In [3]:
ls
In [7]:
with open("unweighted_significant_disease_communities.tsv") as f:
c = csv.reader(f,delimiter="\t")
tabstrings = list(c)
In [19]:
t = tabstrings[1][3]
In [67]:
def texSI(t):
t = "{:.2e}".format(float(t))
t = t.split("e")
t = r"$" + t[0] + r"\e{" + t[1] + r"}" + "$"
return t
In [85]:
with open("unweighted_significant_disease_communities.tex","w") as f:
for i,l in enumerate(tabstrings):
if i==0:
f.write(" ".join([r" & ".join(l[:4]+[l[-2]]), r"\\", "\n"]))
else:
l = l[:3] + map(texSI,l[3:6]) + l[6:]
f.write(" ".join([r" & ".join(l[:4]+[l[-2]]), r"\\", "\n"]))
In [86]:
!head unweighted_significant_disease_communities.tex
In [87]:
with open("weighted_significant_disease_communities.tsv") as f:
c = csv.reader(f,delimiter="\t")
tabstrings = list(c)
In [88]:
with open("weighted_significant_disease_communities.tex","w") as f:
for i,l in enumerate(tabstrings):
if i==0:
f.write(" ".join([r" & ".join(l[:4]+[l[-2]]), r"\\", "\n"]))
else:
l = l[:3] + map(texSI,l[3:6]) + l[6:]
f.write(" ".join([r" & ".join(l[:4]+[l[-2]]), r"\\", "\n"]))